package cn.itsource.basic.util;

import lombok.Data;

@Data
public class AjaxResult {

    private Boolean success;

    private String msg;

    private Object resultObj;

    public static AjaxResult me() {
        return new AjaxResult();
    }

    public AjaxResult success() {
        return me().setSuccess(true).setMsg("操作成功！");
    }

    public AjaxResult success(Object obj) {
        return me().setSuccess(true).setMsg("操作成功！").setResultObj(obj);
    }

    public AjaxResult fail() {
        return me().setSuccess(false).setMsg("操作失败！");
    }

    public AjaxResult fail(String msg) {
        return me().setSuccess(false).setMsg(msg);
    }


    public AjaxResult setResultObj(Object obj) {
        this.resultObj = obj;
        return this;
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }
}
